import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const router = new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      name: 'Home',
      component: () => import('@/views/Home'),
      hidden: true,
      // redirect: '/index',//首页
      redirect: '/UserList',//用户信息页
      children:[
        /* 
          Gis地图
        */
        {path: '/Map', name: 'Map', component: ()=>import('@/views/GisMap/Map/Map.vue')},
        /* 
          保障体系
        */
        {path: '/Guarantee', name: 'Guarantee', component: ()=>import('@/views/GuaranteeSystem/Guarantee/Guarantee.vue')},


        // 轨迹管理
        {path: '/Locusmanage', name: 'Locusmanage', component: ()=>import('@/views/Locusmanage/Locus/Locusmanage.vue')},
        {path: '/Watermanage', name: 'Watermanage', component: ()=>import('@/views/Locusmanage/Watermanage/Watermanage.vue')},

        // 用户管理
        {path: '/UserList', name: 'UserList', component: ()=>import('@/views/UserManage/UserList/UserList.vue')},
        {path: '/RoleManage', name: 'RoleManage', component: ()=>import('@/views/UserManage/RoleManage/RoleManage.vue')},
        {path: '/ResourceManage', name: 'ResourceManage', component: ()=>import('@/views/UserManage/ResourceManage/ResourceManage.vue')},
        {path: '/LogManage', name: 'LogManage', component: ()=>import('@/views/UserManage/LogManage/LogManage.vue')},

        // 运营指挥
        {path: '/InfoQuery', name: 'InfoQuery', component: ()=>import('@/views/Operational/InfoQuery/InfoQuery.vue')},
        {path: '/InfoStatistics', name: 'InfoStatistics', component: ()=>import('@/views/Operational/InfoStatistics/InfoStatistics.vue')},
        {path: '/DenManage', name: 'DenManage', component: ()=>import('@/views/Operational/DenManage/DenManage.vue')},

        // 故障研判   FaultAnalysis
        {path: '/FaultAnalysis', name: 'FaultAnalysis', component: ()=>import('@/views/Fault/FaultAnalysis/FaultAnalysis.vue')},
        {path: '/PipThreshold', name: 'PipThreshold', component: ()=>import('@/views/Fault/PipThreshold/PipThreshold.vue')},
        
        // 保障体系
        {path: '/EmergencyManage', name: 'EmergencyManage', component: ()=>import('@/views/Guarantee/EmergencyManage/EmergencyManage.vue')},
        {path: '/DutyManageme', name: 'DutyManageme', component: ()=>import('@/views/Guarantee/DutyManageme/DutyManageme.vue')},
        {path: '/PlanManage', name: 'PlanManage', component: ()=>import('@/views/Guarantee/PlanManage/PlanManage.vue')},
        {path: '/ExpertManage', name: 'ExpertManage', component: ()=>import('@/views/Guarantee/ExpertManage/ExpertManage.vue')},
        // 监控设备
        {path: '/MonitorDev', name: 'MonitorDev', component: ()=>import('@/views/MonitorDev/MonitorDev.vue')},
        // 工单系统
        {path: '/HistoryOrder', name: 'HistoryOrder', component: ()=>import('@/views/WorkOrder/HistoryOrder/HistoryOrder.vue')},
        {path: '/OrderData', name: 'OrderData', component: ()=>import('@/views/WorkOrder/OrderData/OrderData.vue')},
        {path: '/OrderList', name: 'OrderList', component: ()=>import('@/views/WorkOrder/OrderList/OrderList.vue')},
        // 综合调度
        // 管线管理
        {path: '/PipelineManage', name: 'PipelineManage', component: ()=>import('@/views/AllDispatch/PipelineManage/PipelineManage.vue')},
        {path: '/TaskManage', name: 'TaskManage', component: ()=>import('@/views/AllDispatch/TaskManage/TaskManage.vue')},







        // 其他子系统
        {path: '/DevIndex', name: 'DevIndex', component: ()=>import('@/views/DevSys/DevIndex/DevIndex.vue')},

        {path: '/DevList', name: 'DevList', component: ()=>import('@/views/DevSys/DevDevManage/DevList/DevList.vue')},
        {path: '/DevEdit', name: 'DevEdit', component: ()=>import('@/views/DevSys/DevDevManage/DevEdit/DevEdit.vue')},

        {path: '/DevNowManage', name: 'DevNowManage', component: ()=>import('@/views/DevSys/DevDataManage/DevNowManage/DevNowManage.vue')},
        {path: '/DevHisManage', name: 'DevHisManage', component: ()=>import('@/views/DevSys/DevDataManage/DevHisManage/DevHisManage.vue')},
        {path: '/DevDataContrast', name: 'DevDataContrast', component: ()=>import('@/views/DevSys/DevDataManage/DevDataContrast/DevDataContrast.vue')},

        {path: '/DevWarnPreview', name: 'DevWarnPreview', component: ()=>import('@/views/DevSys/DevWarnManage/DevWarnPreview/DevWarnPreview.vue')},
        {path: '/DevWarnNow', name: 'DevWarnNow', component: ()=>import('@/views/DevSys/DevWarnManage/DevWarnNow/DevWarnNow.vue')},
        {path: '/DevWarnHis', name: 'DevWarnHis', component: ()=>import('@/views/DevSys/DevWarnManage/DevWarnHis/DevWarnHis.vue')},
        {path: '/DevWarnSet', name: 'DevWarnSet', component: ()=>import('@/views/DevSys/DevWarnManage/DevWarnSet/DevWarnSet.vue')},


        //  二供设备
        {path: '/pump', name: 'pump', component: ()=>import('@/views/SecondarySupply/site/pump.vue')},
        {path: '/industry', name: 'industry', component: ()=>import('@/views/SecondarySupply/site/industry.vue')},
        {path: '/industrys', name: 'industrys', component: ()=>import('@/views/SecondarySupply/site/industrys.vue')},
        {path: '/channel', name: 'channel', component: ()=>import('@/views/SecondarySupply/devices/channel.vue')},
        {path: '/list', name: 'list', component: ()=>import('@/views/SecondarySupply/devices/list.vue')},
        {path: '/history', name: 'history', component: ()=>import('@/views/SecondarySupply/devices/history.vue')},
        {path: '/actual', name: 'actual', component: ()=>import('@/views/SecondarySupply/devices/actual.vue')},
        // {path: '/actuallist', name: 'actuallist', component: ()=>import('@/views/SecondarySupply/devices/actuallist.vue')},
        {path: '/actuallists', name: 'actuallists', component: ()=>import('@/views/SecondarySupply/devices/actuallists.vue')},
        {path: '/actuals', name: 'actuals', component: ()=>import('@/views/SecondarySupply/devices/actuals.vue')},
        {path: '/historys', name: 'historys', component: ()=>import('@/views/SecondarySupply/devices/historys.vue')},
        {path: '/scene', name: 'scene', component: ()=>import('@/views/SecondarySupply/records/scene.vue')},
        // {path: '/scenelist', name: 'scenelist', component: ()=>import('@/views/SecondarySupply/records/scenelist.vue')},
        {path: '/scenelists', name: 'scenelists', component: ()=>import('@/views/SecondarySupply/records/scenelists.vue')},
        {path: '/channelscene', name: 'channelscene', component: ()=>import('@/views/SecondarySupply/records/channelscene.vue')},
        {path: '/sceneactual', name: 'sceneactual', component: ()=>import('@/views/SecondarySupply/records/sceneactual.vue')},
        {path: '/scenehistory', name: 'scenehistory', component: ()=>import('@/views/SecondarySupply/records/scenehistory.vue')}
      

      ]
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login/Login.vue')
    },
  ]
})


router.beforeEach((to,from,next)=>{
  const blackSpace = ['UserList']
  const token = window.localStorage.getItem('token')
  if(blackSpace.includes(to.name)){
    if(token){
      next()
    }else{
      next({name:'login'})
    }
  }else{
    next()
  }
  // console.log(window.localStorage.getItem('token'),to,from,blackSpace)
  // console.log(!!(blackSpace.includes(to.name) && token))
  // if(!!(blackSpace.includes(to.name) && token)) next()
  // else next({name:'login'})
})
export default router